package cate.game.role.bag.fairy;

import cate.common.table.d.GDObj;
import cate.common.table.item.fairy.row.FairyBaseRow;
import cate.game.GameBody;
import cate.game.play.support.PlayBuildContext;
import cate.game.role.Role;
import cate.game.role.bag.item.BaseBagItem;
import com.fasterxml.jackson.annotation.JsonIgnore;
import cp.solution.pattern.ICopiable;
import easy.java.dev.note.NoteClass;

import java.util.HashSet;
import java.util.Set;

@NoteClass(value = "灵器")
public class Fairy extends BaseBagItem implements ICopiable<Fairy> {

    public Fairy(){}

    public Fairy(Role role, int tid, long num){
        super(role, GDObj.Type.FAIRY, tid, num);
        initialize(role);
    }

    @JsonIgnore
    public Set<Integer> getSkills(PlayBuildContext ctx, int protoId) {
        FairyBaseRow row = getTpl(ctx);
        if (row == null) {
            return new HashSet<>();
        }
        // 专属英雄穿戴才有技能
        if (row.isExclusive(protoId)) {
            return row.skills;
        } else {
            return new HashSet<>();
        }
    }

    @Override
    @JsonIgnore
    public FairyBaseRow getTpl(PlayBuildContext ctx) {
        return ctx.fairyExcel().base.get(tid);
    }

    @Override
    public FairyBaseRow getTpl(GameBody game) {
        return getTpl(game.fight.getPlayBuildContext());
    }


    @Override
    public Fairy copy() {
        Fairy cp = new Fairy();
        super.copy(cp);
        return cp;
    }
}
